package cn.xiqi.cms.action;

import java.util.HashMap;
import java.util.Map;

import cn.xiqi.cms.oper.AccountOper;
import net.sf.json.JSON;
import net.sf.json.JSONObject;

public class AccountAction extends BaseAction {

	private static final long serialVersionUID = -7441627120462307705L;
	private Map<String, Object> map;
	private JSON json;
	
	public String changepsw(){
		int userid;
		String password;
		boolean b;
		AccountOper oper = new AccountOper();
		
		map = new HashMap<>();
		userid = Integer.valueOf(super.getParameter("userid"));
		password = super.getParameter("password");
		b = oper.changepsw(userid, password);
		map.put("success", b);
		json = JSONObject.fromObject(map);
		return SUCCESS;
	}
	
	public String isExist(){
		String account;
		boolean b;
		AccountOper oper = new AccountOper();
		
		account = super.getParameter("account");
		b = oper.isExist(account);
		map = new HashMap<>();
		map.put("exist", b);
		json = JSONObject.fromObject(map);
		return SUCCESS;
	}

	public JSON getJson() {
		return json;
	}

	public void setJson(JSON json) {
		this.json = json;
	}
}
